package nacos.example.config;

import com.alibaba.cloud.nacos.NacosConfigManager;
import com.alibaba.cloud.nacos.client.NacosPropertySourceLocator;
import jakarta.annotation.PostConstruct;
import jakarta.annotation.Resource;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.env.Environment;
import org.springframework.core.env.PropertySource;

@Configuration
public class CustomNacosPropertySourceLocator extends NacosPropertySourceLocator {
    @Resource
    Environment environment;

    public CustomNacosPropertySourceLocator(NacosConfigManager nacosConfigManager) {
        // TODO 修改server-addr
        super(nacosConfigManager);
    }

    @PostConstruct
    public PropertySource<?> locate() {
        return super.locate(environment);
    }
}
